const express = require("express");
const router = express.Router();
const { Setting } = require("../models");
const { success, failure } = require("../utils/responses");
const { NotFoundError } = require("../utils/errors");

/**
 * 查询系统设置列表
 * @api {get} /settings
 */
router.get("/", async (req, res) => {
  try {
    const settings = await Setting.findOne();
    if (!settings) {
      throw new NotFoundError("设置不存在");
    }
    success(res, "查询系统设置列表成功", { settings });
  } catch (error) {
    failure(res, error);
  }
});

module.exports = router;
